﻿using System.Collections.Generic;
using AutoMapper;
using FluentValidation.Results;
using FikriKibar.Entities.Composite.BaseModels;
using FikriKibar.Entities.Concrete;
using FikriKibar.Common.Validation.Entities;

namespace FikriKibar.Common.Validation.FluentValidation.Keyword
{
    public class AddValidator : FluentBaseValidator
    {
        public override bool IsValid { get; set; }

        private AddRules _rules;
        private readonly AddModel<KeywordLanguageLine> _model;

        public AddValidator(AddModel<KeywordLanguageLine> model)
        {
            _model = model;
        }

        public override List<FikriKibarValidationResult> Validate()
        {
            _rules = new AddRules();
            var results = _rules.Validate(_model);
            var t = Mapper.Map<IList<ValidationFailure>, IList<FikriKibarValidationResult>>(results.Errors);
            ValidationResults.AddRange(t);
            IsValid = results.IsValid;
            return ValidationResults;
        }


    }
}
